/**
 * Created by GuoDapeng on 14-9-5.
 */

//必须引用下面的文件
//"ROOT_FOLDER/jsLib/jquery/jquery-2.1.1.js",
//"ROOT_FOLDER/jsLib/jquery/jquery.json.js",
//"ROOT_FOLDER/jsLib/jquery/jquery.ajaxRequest.js"
//TODO: 参数统一 变成 option object 传参（orderSystem.XXX({PARA:1,PARA:2})） 下一版接口全面实现


var OrderingSystem = function () {
    //  URL 请求地址
    var url = 'http://192.168.6.60/server/php/index.php';//2015年7月22日 15:56:27 李浩测试地址
    //var url = '../../../serverStable/php/index.php';
    //var url = '../../../bqcProduct/php/index.php';

    var EARTH_RADIUS = 6378137.0;//单位M
    var PI = Math.PI;

    //一半请求的开关，默认异步，设置同步请求时只生效一次请求
    var async = true;


    //new Date().getTime()
//	var mdate = new Date();
//	var clientTime=mdate.getFullYear()+"-"+(mdate.getMonth()+1)+"-"+mdate.getDate()+' '+mdate.getHours()+':'+mdate.getMinutes()+':'+mdate.getSeconds();

    var setClientTime = function () {
        var mdate = new Date();
        var clientTime = mdate.getFullYear() + "-" + (mdate.getMonth() + 1) + "-" + mdate.getDate() + ' ' + mdate.getHours() + ':' + mdate.getMinutes() + ':' + mdate.getSeconds();

        seconds = 60;   //seconds有值就直接赋值，没有为0，这个根php不一样。
        var expires = "";
        if (seconds != 0) {      //设置cookie生存时间
            var date = new Date();
            date.setTime(date.getTime() + (seconds * 1000));
            expires = "; expires=" + date.toGMTString();
        }
        var array = window.location.hostname.split(".");
        document.cookie = "clientTime=" + escape(clientTime) + expires + "; path=/" + "; domain=" + array[array.length - 2] + "." + array[array.length - 1];//转码并赋值
    };


    /**
     * 发送请求
     * @param out
     * @param successFunction
     * @param errorFunction
     * @param completeFunction
     */
    var request = function (out, successFunction, errorFunction, completeFunction) {
        setClientTime();
        var request = new AjaxRequest(url, JSON.stringify(out), function (data, textStatus) {
            if (data.error) {
                alert("error:" + data.error + "errmsg" + data.errmsg[0]);
                console.error("server logic error:", data, 'caused by:', out);
            }

            for (var i in data["cookieData"]) {
                if (data["cookieData"].hasOwnProperty(i)) {
                    localStorage.setItem(i, JSON.stringify(data["cookieData"][i]));
                }
            }

            if (typeof successFunction !== 'undefined') {
                successFunction(data, textStatus);
            }
        }, function (XMLHttpRequest, textStatus, errorThrown) {
            if (typeof errorFunction === 'undefined') {
                console.error("AjaxRequestError:", "XMLHttpRequest:", XMLHttpRequest, 'textStatus:', textStatus, "errorThrown:", errorThrown);
            } else {
                errorFunction(XMLHttpRequest, textStatus, errorThrown);
            }
        }, function (XMLHttpRequest, textStatus) {
            if (typeof completeFunction === 'undefined') {
                console.info("AjaxRequestComplete:", "XMLHttpRequest:", XMLHttpRequest, 'textStatus:', textStatus);
            } else {
                completeFunction(XMLHttpRequest, textStatus);
            }
        });
        request.setAsync(async);
        async = true;
        request.doAjax();
    };

    var getRad = function (d) {
        return d * PI / 180.0;
    };

    /**
     * 上传文件
     * @param id
     * @param successFunction
     * @returns {boolean}
     */
    var ajaxFileUpload = function (id, successFunction) {
        $.ajaxFileUpload
        (
            {
                url          : url + "?controller=file&action=setImage",
                secureuri    : false,
                fileElementId: id,
                dataType     : 'json',//echo 一定是json字符串
                beforeSend   : function () {
                    $("#loading").show();
                },
                complete     : function () {
                    $("#loading").hide();
                },
                success      : successFunction,
                error        : function (data, status, e) {
                    if (typeof errorFunction === 'undefined') {
                        console.log(e);
                    } else {
                        errorFunction(data, status, e);
                    }

                }
            }
        );
        return false;
    };

    /**
     * 接口方法
     */
    return {
        setRequestAsync: function (value) {
            async = value;
        },

        getWindPath: function (options) {
            var out = {
                "params"    : {},
                "controller": "home",
                "action"    : "getWindPath"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getServerPath: function (options) {
            var out = {
                "params"    : {},
                "controller": "home",
                "action"    : "getServerPath"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /***********************************
         * home
         ***********************************/
        checkTheInternet: function (options) {
            var out = {
                "params"    : {},
                "controller": "home",
                "action"    : "checkTheInternet"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getVersions: function (options) {
            var out = {
                "params"    : {},
                "controller": "home",
                "action"    : "getVersions"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getWindVersions: function (options) {
            var out = {
                "params"    : {},
                "controller": "home",
                "action"    : "getWindVersions"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getWindSDKVersions: function (options) {
            var out = {
                "params"    : {},
                "controller": "home",
                "action"    : "getWindSDKVersions"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getServerDBStatus: function (options) {
            var out = {
                "params"    : {},
                "controller": "home",
                "action"    : "getServerDBStatus"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 测试数据库延迟
         * @param options
         */
        testDB: function (options) {
            var out = {
                "params"    : {},
                "controller": "home",
                "action"    : "testDB"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /***********************************
         * 餐厅的操作
         ***********************************/

        /**
         * 创建一个新的餐厅
         */
        newRestaurant: function (obj, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "RName"         : obj.RName,
                    "RMobile"       : obj.RMobile,
                    "address_city"  : obj.address_city,
                    "address_street": obj.address_street,
                    "address_suburb": obj.address_suburb,
                    "desc"          : obj.desc
                },
                "controller": "restaurant",
                "action"    : "newRestaurant"
            };
            request(out, successFunction, errorFunction, completeFunction)
        },

        /**
         * 删除一家店
         */
        deleteRestaurant: function (rId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "RId": rId
                },
                "controller": "restaurant",
                "action"    : "deleteRestaurant"
            };
            request(out, successFunction, errorFunction, completeFunction)
        },

        /**
         * 修改店家的名字
         */
        setRestaurantName: function (newFName, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "newName": newFName
                },
                "controller": "restaurant",
                "action"    : "setRestaurantName"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        setRestaurantPhone: function (newRPhone, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "newRPhone": newRPhone
                },
                "controller": "restaurant",
                "action"    : "setRestaurantPhone"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 修改店家的logo
         */
        setRestaurantLogo: function (newFLogo, successFunction, errorFunction, completeFunction) {
            ajaxFileUpload(newFLogo, function (data) {
                var out = {
                    "params"    : {
                        "newFLogo": data.data.imageId
                    },
                    "controller": "restaurant",
                    "action"    : "setRestaurantLogo"
                };
                request(out, successFunction, errorFunction, completeFunction);
            });
        },

        setRestaurantLogoByBase64: function (options) {
            var out = {
                "params"    : {
                    "base64ImageString": options.base64ImageString
                },
                "controller": "restaurant",
                "action"    : "setRestaurantLogoByBase64"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        setRestaurantTypeLogo: function (options) {
            ajaxFileUpload(options.imageId, function (data) {
                var out = {
                    "params"    : {
                        "imageId": data.data.imageId
                    },
                    "controller": "restaurant",
                    "action"    : "setRestaurantTypeLogo"
                };
                request(out, options.successFunction, options.errorFunction, options.completeFunction);
            });
        },

        setRestaurantTypeLogoByBase64: function (options) {
            var out = {
                "params"    : {
                    "base64ImageString": options.base64ImageString
                },
                "controller": "restaurant",
                "action"    : "setRestaurantTypeLogoByBase64"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        setMemberLevelDesc: function (options) {
            var out = {
                "params"    : {
                    "memberLevelDesc": options.memberLevelDesc
                },
                "controller": "restaurant",
                "action"    : "setMemberLevelDesc"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        delEzcMember: function (options) {
            var out = {
                "params"    : {
                    "mobile": options.mobile
                },
                "controller": "member",
                "action"    : "delEzcMember"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 获得店家logo
         * @param options
         */
        getRestaurantLogo: function (options) {
            var out = {
                "params"    : {},
                "controller": "restaurant",
                "action"    : "getRestaurant"
            };

            request(out, function (data) {
                var urlData = {
                    "data"  : [],
                    "error" : data.error,
                    "errmsg": data.errmsg
                };
                if (data.error == 0) {
                    try {
                        urlData.data = [{picUrl: url + "?controller=file&action=getImage&image=" + data.data[0].RLogo}];
                    } catch (e) {
                        urlData.data = [{picUrl: url + "?controller=file&action=getImage&image="}];
                    }
                }
                options.successFunction(urlData);
            }, options.errorFunction, options.completeFunction);
        },

        /**
         * 获得店家 typeLogo
         * @param options
         */
        getRestaurantTypeLogo: function (options) {
            var out = {
                "params"    : {},
                "controller": "restaurant",
                "action"    : "getRestaurant"
            };

            request(out, function (data) {
                var urlData = {
                    "data"  : [],
                    "error" : data.error,
                    "errmsg": data.errmsg
                };
                if (data.error == 0) {
                    try {
                        urlData.data = [{picUrl: url + "?controller=file&action=getImage&image=" + data.data[0].typeLogo}];
                    } catch (e) {
                        urlData.data = [{picUrl: url + "?controller=file&action=getImage&image="}];
                    }
                }
                options.successFunction(urlData);
            }, options.errorFunction, options.completeFunction);
        },

        /**
         * 修改店家地址
         */
        setRestaurantAddress: function (newFAddress, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "address_city"  : newFAddress.address_city,
                    "address_street": newFAddress.address_street,
                    "address_suburb": newFAddress.address_suburb
                },
                "controller": "restaurant",
                "action"    : "setRestaurantAddress"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        setRestaurantCoords: function (options) {
            var out = {
                "params"    : {
                    "lat": options.lat,
                    "lng": options.lng
                },
                "controller": "restaurant",
                "action"    : "setRestaurantCoords"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getRestaurantCoords: function (options) {
            var out = {
                "params"    : {},
                "controller": "restaurant",
                "action"    : "getRestaurantCoords"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        setRestaurantDeliveryDistance: function (options) {
            var out = {
                "params"    : {
                    "deliveryDistance": options.deliveryDistance
                },
                "controller": "restaurant",
                "action"    : "setRestaurantDeliveryDistance"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getRestaurantDeliveryDistance: function (options) {
            var out = {
                "params"    : {},
                "controller": "restaurant",
                "action"    : "getRestaurantDeliveryDistance"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 设置订桌时支付的定金
         * @param options
         */
        setRestaurantBond: function (options) {
            var out = {
                "params"    : {
                    "bond": options.bond
                },
                "controller": "restaurant",
                "action"    : "setRestaurantBond"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 获得一家店的接口
         */
        getRestaurant: function (successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {},
                "controller": "restaurant",
                "action"    : "getRestaurant"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 读取店家列表【有争议，暂时不实现】
         */
        getRestaurantList: function (successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {},
                "controller": "restaurant",
                "action"    : "getRestaurantList"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 订桌时，获得是否需要支付定金
         * @param options
         */
        needBond: function (options) {
            var out = {
                "params"    : {},
                "controller": "restaurant",
                "action"    : "needBond"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        setResAnnounce: function (options) {
            var out = {
                "params"    : {
                    "content": options.content
                },
                "controller": "restaurant",
                "action"    : "setResAnnounce"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getResAnnounce: function (options) {
            var out = {
                "params"    : {
                    "content": options.content
                },
                "controller": "restaurant",
                "action"    : "getResAnnounce"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /***********************************
         * 分类的操作
         * *********************************/

        /**
         * 创建一个分类
         */
        newCpGroup: function (cpGroup, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    group_name: cpGroup.group_name,
                    group_memo: cpGroup.group_memo,
                    priority  : cpGroup.priority
                },
                "controller": "cpGroup",
                "action"    : "newCpGroup"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 删除分类
         */
        deleteGroup: function (gId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "GId": gId
                },
                "controller": "cpGroup",
                "action"    : "deleteGroup"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 修改分类名字
         */
        setGroupName: function (gId, newGName, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "GId"     : gId,
                    "newGName": newGName
                },
                "controller": "cpGroup",
                "action"    : "setGroupName"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 获得店家菜品的分类
         */
        getCpGroupList: function (successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {},
                "controller": "cpGroup",
                "action"    : "getCpGroupList"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        setCpGroupPriority: function (options) {
            var out = {
                "params"    : {
                    "GId"     : options.gId,
                    "priority": options.priority
                },
                "controller": "cpGroup",
                "action"    : "setPriority"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /***********************************
         * 菜品的操作
         ***********************************/

        /**
         * 添加新菜品
         */
        newCp: function (obj, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "cp_desc" : obj.cp_desc,//菜简介
                    "cp_name" : obj.cp_name,//菜品名字
                    "group_id": obj.group_id,//分类id
                    "price"   : obj.price,//价格
                    "priority": obj.priority
                },
                "controller": "cp",
                "action"    : "newCp"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 删除菜品
         */
        deleteCp: function (cId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "CId": cId
                },
                "controller": "cp",
                "action"    : "deleteCp"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 修改菜品名字
         */
        setCpName: function (cId, newCName, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "CId"     : cId,
                    "newCName": newCName
                },
                "controller": "cp",
                "action"    : "setCpName"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        setCpisFree: function (options) {
            var out = {
                "params"    : {
                    "lineItemId": options.lineItemId,
                    "Reason"    : options.Reason,
                    "freeState" : options.freeState
                },
                "controller": "order",
                "action"    : "setCpisFree"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 修改菜品价格
         */
        setCpPrice: function (cId, newCPrice, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "CId"      : cId,
                    "newCPrice": newCPrice
                },
                "controller": "cp",
                "action"    : "setCpPrice"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 设置菜品会员价
         * @param options
         */
        setCpMemberPrice: function (options) {
            var out = {
                "params"    : {
                    "cpId"            : options.cpId,
                    "newCpMemberPrice": options.newCpMemberPrice
                },
                "controller": "cp",
                "action"    : "setCpMemberPrice"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 启用一到菜品的会员价格
         * @param options
         */
        activeMemberPrice: function (options) {
            var out = {
                "params"    : {
                    "cpId"             : options.cpId,
                    "enableMemberPrice": true
                },
                "controller": "cp",
                "action"    : "setEnableMemberPrice"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 停用一到菜品的会员价格
         * @param options
         */
        deactiveMemberPrice: function (options) {
            var out = {
                "params"    : {
                    "cpId"             : options.cpId,
                    "enableMemberPrice": false
                },
                "controller": "cp",
                "action"    : "setEnableMemberPrice"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 修改菜品简介
         */
        setCpDesc: function (cId, newCDesc, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "CId"     : cId,
                    "newCDesc": newCDesc
                },
                "controller": "cp",
                "action"    : "setCpDesc"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 修改菜品图片
         */
        setCpImage: function (cId, newCpImage, successFunction, errorFunction, completeFunction) {
            ajaxFileUpload(newCpImage, function (data) {
                var out = {
                    "params"    : {
                        "CId"      : cId,
                        "use"      : "image",
                        "newCImage": data.data.imageId
                    },
                    "controller": "cp",
                    "action"    : "setCpImage"
                };
                request(out, successFunction, errorFunction, completeFunction);
            });
        },

        setCpImageByBase64: function (options) {
            var out = {
                "params"    : {
                    "cpId"             : options.cpId,
                    "base64ImageString": options.base64ImageString
                },
                "controller": "cp",
                "action"    : "setCpImageByBase64"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 修改菜品图片
         */
        setCpIcon: function (cId, newCpIcon, successFunction, errorFunction, completeFunction) {
            ajaxFileUpload(newCpIcon, function (data) {
                var out = {
                    "params"    : {
                        "CId"      : cId,
                        "use"      : "icon",
                        "newCImage": data.data.imageId
                    },
                    "controller": "cp",
                    "action"    : "setCpImage"
                };
                request(out, successFunction, errorFunction, completeFunction);
            });
        },

        setCpIconByBase64: function (options) {
            var out = {
                "params"    : {
                    "cpId"             : options.cpId,
                    "base64ImageString": options.base64ImageString
                },
                "controller": "cp",
                "action"    : "setCpIconByBase64"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 修改菜品分类
         */
        setCpGroup: function (cId, gId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "CId": cId,
                    "GId": gId
                },
                "controller": "cp",
                "action"    : "setCpGroup"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 修改菜品星
         */
        setCpStar: function (cId, star, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "CId" : cId,
                    "Star": star
                },
                "controller": "cp",
                "action"    : "setCpStar"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 修改菜品是否还有的状态
         */
        setInStock: function (cId, condition, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "CId"  : cId,
                    "Stock": condition
                },
                "controller": "cp",
                "action"    : "setInStock"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        setCpPriority: function (options) {
            var out = {
                "params"    : {
                    "CId"     : options.cId,
                    "priority": options.priority
                },
                "controller": "cp",
                "action"    : "setPriority"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getTableByNormalNewLineItem: function (options) {
            var out = {
                "params"    : {},
                "controller": "order",
                "action"    : "getTableByNormalNewLineItem"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 读取菜品是否还有的状态
         */
        getStockStatus: function (cId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "CId": cId
                },
                "controller": "cp",
                "action"    : "getStockStatus"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 获得菜品销量
         */
        getCpSalesVolume: function (cId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "CId": cId
                },
                "controller": "cp",
                "action"    : "getCpSalesVolume"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        getCpSalesVolumeByCpIdAndDateRange: function (cId, start, end, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "CId"  : cId,
                    "start": start,
                    "end"  : end
                },
                "controller": "cp",
                "action"    : "getCpSalesVolumeByCpIdAndDateRange"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 获得一段时间的菜品销量
         */
        getDailyCpSalesVolumeListByCpIdAndDateRange: function (cId, start, end, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "CId"  : cId,
                    "start": start,
                    "end"  : end
                },
                "controller": "cp",
                "action"    : "getDailyCpSalesVolumeListByCpIdAndDateRange"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        getCpSalesVolumeListByDateRange: function (start, end, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "start": start,
                    "end"  : end
                },
                "controller": "cp",
                "action"    : "getCpSalesVolumeListByDateRange"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 读取店家一个菜品
         */
        getCp: function (cId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "CId": cId
                },
                "controller": "cp",
                "action"    : "getCp"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 查看分类下的菜品
         */
        getGroupCpList: function (gId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "groupId": gId
                },
                "controller": "cp",
                "action"    : "getGroupCpList"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        getCpSalesCountByDate: function (options) {
            var out = {
                "params"    : {
                    "cpId" : options.cpId,
                    "start": options.start,
                    "end"  : options.end
                },
                "controller": "cp",
                "action"    : "getCpSalesCountByDate"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 读取店家菜品列表
         */
        getRestaurantCpList: function (successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {},
                "controller": "cp",
                "action"    : "getRestaurantCpList"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * getMenu
         */
        getMenu: function (successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {},
                "controller": "cp",
                "action"    : "getMenu"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        setCpRelish: function (options) {
            var out = {
                "params"    : options.cpAndRelishList,//[{"cpId":"xxx","relish":"yyy"},...]
                "controller": "cp",
                "action"    : "setCpRelish"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getCpRelishList: function (options) {
            var out = {
                "params"    : {},
                "controller": "cp",
                "action"    : "getCpRelishList"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        setProductionTime: function (options) {
            var out = {
                "params"    : {
                    "cpId"          : options.cpId,
                    "productionTime": options.productionTime
                },
                "controller": "cp",
                "action"    : "setProductionTime"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /***********************************
         * 订单的操作（6个月内）
         ***********************************/

        /**
         * 写 pool
         */
        postPoolItem: function (pool, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : pool,
                "controller": "pool",
                "action"    : "postPoolItem"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 获得 pool
         */
        getPoolItemByOId: function (oId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "OId": oId
                },
                "controller": "pool",
                "action"    : "getPoolItemByOId"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        //Order

        /**
         * 创建订单
         */
        newOrder: function (order, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : order,
                "controller": "order",
                "action"    : "newOrder"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 创建外卖订单
         * @param options
         */
        newTakeoutOrder: function (options) {
            var out = {
                "params"    : {
                    "name"                  : options.name,
                    "sex"                   : options.sex,
                    "mobile"                : options.mobile,
                    "takeawayAddressCity"   : options.takeawayAddressCity,
                    "takeawayAddressSuburb" : options.takeawayAddressSuburb,
                    "takeawayAddressAddress": options.takeawayAddressAddress,
                    "itemList"              : options.itemList
                },
                "controller": "order",
                "action"    : "newTakeoutOrder"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 云易会员创建外卖订单
         * @param options
         */
        createTakeoutOrderByEzcMember: function (options) {
            var out = {
                "params"    : {
                    "ezcMemberId"           : options.ezcMemberId,
                    "mobile"                : options.mobile,
                    "takeawayAddressCity"   : options.takeawayAddressCity,
                    "takeawayAddressSuburb" : options.takeawayAddressSuburb,
                    "takeawayAddressAddress": options.takeawayAddressAddress
                },
                "controller": "order",
                "action"    : "createTakeoutOrderByEzcMember"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 发起微信JSAIP支付来支付外卖订单
         * @param options
         */
        ezcMemberWeiXinPayTakeoutOrder: function (options) {
            var out = {
                "params"    : {
                    "ezcMemberId": options.ezcMemberId,
                    "orderId"    : options.orderId,
                    "tokenIdList": options.tokenIdList
                },
                "controller": "order",
                "action"    : "ezcMemberWeiXinPayTakeoutOrder"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 发起微信JSAPI支付来支付预订订单
         * @param options
         */
        ezcMemberWeiXinPayReserveOrder: function (options) {
            var out = {
                "params"    : {
                    "ezcMemberId": options.ezcMemberId,
                    "orderId"    : options.orderId,
                    "tokenIdList": options.tokenIdList
                },
                "controller": "order",
                "action"    : "ezcMemberWeiXinPayReserveOrder"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 发起微信JSAPI支付支付定金
         * @param options
         */
        ezcMemberWeiXinPayBond: function (options) {
            var out = {
                "params"    : {
                    "ezcMemberId": options.ezcMemberId,
                    "orderId"    : options.orderId
                },
                "controller": "order",
                "action"    : "ezcMemberWeiXinPayBond"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 店员预订
         * @param options
         */
        createPreOrder: function (options) {
            var out = {
                "params"    : {
                    "name"        : options.name,
                    "sex"         : options.sex,
                    "ResMobile"   : options.ResMobile,
                    "ResDate"     : options.ResDate,
                    "ResTime"     : options.ResTime,
                    "tableClassId": options.tableClassId
                },
                "controller": "order",
                "action"    : "createPreOrder"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 云易会员创建预订订单
         * @param options
         */
        createPreOrderByEzcMember: function (options) {
            var out = {
                "params"    : {
                    "ezcMemberId" : options.ezcMemberId,
                    "name"        : options.name,
                    "ResMobile"   : options.ResMobile,
                    "ResDate"     : options.ResDate,
                    "ResTime"     : options.ResTime,
                    "tableClassId": options.tableClassId
                },
                "controller": "order",
                "action"    : "createPreOrderByEzcMember"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 店内员工开台
         */
        createOrder: function (pId, tId, personCount, itemList, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "PId"        : pId,
                    "TId"        : tId,
                    "personCount": personCount,
                    "ItemList"   : itemList
                },
                "controller": "order",
                "action"    : "createOrder"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 会员开台
         * @param options
         */
        memberOpenTable: function (options) {
            var out = {
                "params"    : {
                    "TId"        : options.TId,
                    "memberId"   : options.memberId,
                    "personCount": options.personCount,
                    "openId"     : options.openId,
                    "nickName"   : options.nickName//选填
                },
                "controller": "order",
                "action"    : "memberOpenTable"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 云易会员开台
         * @param options
         */
        ezcMemberOpenTable: function (options) {
            var out = {
                "params"    : {
                    "tableId" : options.tableId,
                    "memberId": options.memberId,
                    "openId"  : options.openId,
                    "nickName": options.nickName
                },
                "controller": "order",
                "action"    : "ezcMemberOpenTable"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 删除订单
         */
        deleteOrder: function (oId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "OId": oId
                },
                "controller": "order",
                "action"    : "deleteOrder"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 取消订单
         */
        cancelOrder: function (oId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "OId": oId
                },
                "controller": "order",
                "action"    : "cancelOrder"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 取消订单需填写理由
         */


        cancelReasonOrder: function (options) {
            var out = {
                "params"    : {
                    "orderId": options.orderId,
                    "reason" : options.reason
                },
                "controller": "order",
                "action"    : "cancelReasonOrder"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },


        /**
         * 错误订单
         */
        tagWrongOrder: function (oId, reason, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "OId"   : oId,
                    "reason": reason
                },
                "controller": "order",
                "action"    : "tagWrongOrder"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 错误订单条目
         */
        tagWrongLineItem      : function (id, reason, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "LId"        : id,
                    "wrongReason": reason
                },
                "controller": "order",
                "action"    : "tagWrongLineItem"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },
        //TODO: 有个客户删除preorder的东西
        /**
         * 获得店家的所有订单
         */
        getRestaurantOrderList: function (successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {},
                "controller": "order",
                "action"    : "getRestaurantOrderList"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 获得一份订单
         */
        getOrderById        : function (oId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "OId": oId
                },
                "controller": "order",
                "action"    : "getOrderById"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },
        /**
         * 获得一份订单
         */
        getOrderByIdNoSelect: function (oId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "OId": oId
                },
                "controller": "order",
                "action"    : "getOrderByIdNoSelect"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },


        /**
         * 通过会员ID获得 pre 订单
         * @param options
         * @deprecated
         */
        getOrderByWeiXinUid: function (options) {
            var out = {
                "params"    : {
                    "UId": options.uId
                },
                "controller": "order",
                "action"    : "getOrderByWeiXinUid"
            };

            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 通过会员ID获得 pre 订单
         * @param options
         */
        getPreOrderByEzcMemberId: function (options) {
            var out = {
                "params"    : {
                    "ezcMemberId": options.ezcMemberId
                },
                "controller": "order",
                "action"    : "getPreOrderByEzcMemberId"
            };

            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 按照订单状态搜索订单
         */
        getOrderByStatusList: function (orderStatus, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "OrderStatus": orderStatus
                },
                "controller": "order",
                "action"    : "getOrderByStatusList"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 按照订单状态搜索一段时间的订单
         */
        getOrderByStatusAndDateRangeList: function (orderStatus, start, end, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "OrderStatus": orderStatus,
                    "start"      : start,
                    "end"        : end
                },
                "controller": "order",
                "action"    : "getOrderByStatusAndDateRangeList"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 根据店员ID获得一天的各种状态的订单
         */
        getDayOrdertListByStatus: function (options) {
            var out = {
                "params"    : {
                    "start"    : options.start,
                    "end"      : options.end,
                    "orderType": options.orderType,
                    "Status"   : options.Status,
                },
                "controller": "order",
                "action"    : "getDayOrdertListByStatus"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 通过电话搜索 非 billed / closed 的订单
         */
        getOrderByMobile: function (mobile, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "mobile": mobile
                },
                "controller": "order",
                "action"    : "getOrderByMobile"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        getOrderByOptions: function (options) {
            var out = {
                "params"    : options,
                "controller": "order",
                "action"    : "getOrderByOptions"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 修改订单状态
         */
        setOrderStatus: function (oId, status, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "OId"   : oId,
                    "Status": status
                },
                "controller": "order",
                "action"    : "setOrderStatus"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 获得应付价格
         */
        getTotal: function (oId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "OId": oId
                },
                "controller": "order",
                "action"    : "getTotal"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 获得折扣后的价格
         */
        caluAmount: function (orderId, tokenIdList, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "orderId"    : orderId,
                    "tokenIdList": tokenIdList
                },
                "controller": "order",
                "action"    : "caluAmount"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        calculateActuallyAmount: function (options) {
            var out = {
                "params"    : {
                    "orderId"    : options.orderId,
                    "tokenIdList": options.tokenIdList,
                    "memberPay"  : options.memberPay
                },
                "controller": "order",
                "action"    : "calculateActuallyAmount"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getOrderPayTransByOrderId: function (orderId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "OrderId": orderId
                },
                "controller": "order",
                "action"    : "getOrderPayTransByOrderId"

            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        addOrderPayTrans: function (orderId, amount, type, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "orderId": orderId,
                    "amount" : amount,
                    "type"   : type
                },
                "controller": "order",
                "action"    : "addOrderPayTrans"

            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        tagWrongPayTrans: function (id, reason, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "id"         : id,
                    "wrongReason": reason
                },
                "controller": "order",
                "action"    : "tagWrongPayTrans"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        addOrderToken: function (options) {
            var out = {
                "params"    : {
                    "OId"        : options.oId,
                    "tokenIdList": options.tokenIdList
                },
                "controller": "order",
                "action"    : "addOrderToken"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 验证开台验证码
         * @param options
         */
        openTableSmsCapt: function (options) {
            var out = {
                "params"    : {
                    "capt"       : options.capt,
                    "TId"        : options.tId,
                    "personCount": options.personCount,
                    "UId"        : options.UId,
                    "NickName"   : options.NickName
                },
                "controller": "order",
                "action"    : "openTableSmsCapt"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 设置订单口味
         * @param options
         */
        setOrderRequest: function (options) {
            var out = {
                "params"    : {
                    "orderId"       : options.orderId,
                    "commonRequest" : options.commonRequest,
                    "specialRequest": options.specialRequest
                },
                "controller": "order",
                "action"    : "setOrderRequest"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 将订单从 pre 设置为 new
         * @param options
         */
        confirmOrder: function (options) {
            var out = {
                "params"    : {
                    "orderId": options.orderId
                },
                "controller": "order",
                "action"    : "confirmOrder"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 将订单从 pre 设置为 new
         * @param options
         */
        aceeptOrder: function (options) {
            var out = {
                "params"    : {
                    "orderId": options.orderId
                },
                "controller": "order",
                "action"    : "aceeptOrder"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 获得一段时间的订单
         */
        getOrderByDateRange: function (start, end, successFunction, errorFunction, completeFunction) {//new date()
            var out = {
                "params"    : {
                    "start": start,
                    "end"  : end
                },
                "controller": "order",
                "action"    : "getOrderByDateRange"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 已接受的预订订单列表
         * @param options
         */
        getReserveAcceptedOrderList: function (options) {
            var out = {
                "params"    : {},
                "controller": "order",
                "action"    : "getReserveAcceptedOrderList"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 未接受的预订订单列表
         * @param options
         */
        getReserveAwaitOrderList: function (options) {
            var out = {
                "params"    : {},
                "controller": "order",
                "action"    : "getReserveAwaitOrderList"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getTakeoutAwaitOrderList: function (options) {
            var out = {
                "params"    : {},
                "controller": "order",
                "action"    : "getTakeoutAwaitOrderList"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getTakeoutAcceptedOrderList: function (options) {
            var out = {
                "params"    : {},
                "controller": "order",
                "action"    : "getTakeoutAcceptedOrderList"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        //新增未接受的订单列表

        getUnreceivedOrderList: function (options) {
            var out = {
                "params"    : {},
                "controller": "order",
                "action"    : "getUnreceivedOrderList"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },


        //抓取一份订单作为锁定状态

        catchOrderByUid: function (options) {
            var out = {
                "params"    : {
                    'OrderId': options.OrderId,
                },
                "controller": "order",
                "action"    : "catchOrderByUid"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        //释放一份锁定的订单

        freeOrderByUid: function (options) {
            var out = {
                "params"    : {
                    'OrderId': options.OrderId,
                },
                "controller": "order",
                "action"    : "freeOrderByUid"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },


        //获得未接受的外卖订单数量

        getTakeoutAwaitOrderCount: function (options) {
            var out = {
                "params"    : {},
                "controller": "order",
                "action"    : "getTakeoutAwaitOrderCount"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        //获得未接受的预定订单数量

        getReserveAwaitOrderCount: function (options) {
            var out = {
                "params"    : {},
                "controller": "order",
                "action"    : "getReserveAwaitOrderCount"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        //LineItem

        /**
         * 添加 lineItem，老的的订单添加新菜
         */
        addLineItem   : function (oId, lineItemArray, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "OId"          : oId,
                    "lineItemArray": lineItemArray
                },
                "controller": "order",
                "action"    : "addLineItem"

            };
            //console.log(addLineItem);
            request(out, successFunction, errorFunction, completeFunction);
        },
        /**
         * 添加 lineItem 退菜信息
         */
        cancelLineItem: function (options) {
            var out = {
                "params"    : {
                    "itemId": options.itemId,
                    "count" : options.count,
                    "reason": options.reason
                },
                "controller": "order",
                "action"    : "cancelLineItem"
            };

            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        addLineItemList: function (options) {
            var out = {
                "params"    : {
                    "orderId" : options.orderId,
                    "lineItem": options.cpList,
                },
                "controller": "order",
                "action"    : "addLineItemList"
            };

            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getLineItemListCountByOrderId_json: function (options) {
            var out = {
                "params"    : {
                    "orderId": options.orderId,
                    "cp_Id"  : options.cp_Id
                },
                "controller": "order",
                "action"    : "getLineItemListCountByOrderId_json"
            };

            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        addLineItemByPad: function (options) {
            var out = {
                "params"    : {
                    "OId"          : options.oId,
                    "lineItemArray": options.lineItemArray,
                    "PId"          : options.pId
                },
                "controller": "order",
                "action"    : "addLineItemByPad"
            };

            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 添加菜品到临时订单
         * @param options
         */
        setLineItemByWeiXinOpenIdToCart: function (options) {
            var out = {
                "params"    : {
                    "orderId"        : options.orderId,
                    "lineItemArray"  : options.lineItemArray,
                    "name"           : options.name,
                    "ResWeiXinOpenId": options.ResWeiXinOpenId,
                    "clientTime"     : new Date().getTime()
                },
                "controller": "order",
                "action"    : "setLineItemByWeiXinOpenIdToCart"
            };

            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 获得自己的临时订单
         * @param options
         */
        getCartLineItemByOpenId: function (options) {
            var out = {
                "params"    : {
                    "ResWeiXinOpenId": options.ResWeiXinOpenId,
                    "orderId"        : options.orderId
                },
                "controller": "order",
                "action"    : "getCartLineItemByOpenId"
            };

            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 获得所有人临时订单
         * @param options
         */
        getCartLineItem: function (options) {
            var out = {
                "params"    : {
                    "orderId": options.orderId
                },
                "controller": "order",
                "action"    : "getCartLineItem"
            };

            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getPersonPrimaryKeyLineItemListByOrderId: function (options) {
            var out = {
                "params"    : {
                    "orderId": options.orderId
                },
                "controller": "order",
                "action"    : "getPersonPrimaryKeyLineItemListByOrderId"
            };

            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 将菜品添加到订单
         * @param options
         */
        pushCartToOrderLineItem: function (options) {
            var out = {
                "params"    : {
                    "cartLineItemIdList": options.cartLineItemIdList
                },
                "controller": "order",
                "action"    : "pushCartToOrderLineItem"
            };

            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 获得菜品进度
         * @param options
         */
        getLineItemStateHistory: function (options) {
            var out = {
                "params"    : {
                    "lineItemId": options.lineItemId
                },
                "controller": "order",
                "action"    : "getLineItemStateHistory"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getLineItemStateHistoryByOrderId: function (options) {
            var out = {
                "params"    : {
                    "orderId": options.orderId
                },
                "controller": "order",
                "action"    : "getLineItemStateHistoryByOrderId"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 改变 lineItem 状态
         */
        setLineItemStatus: function (lId, status, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "LId"   : lId,
                    "Status": status
                },
                "controller": "order",
                "action"    : "setLineItemStatus"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        setLineItemCount: function (options) {
            var out = {
                "params"    : {
                    "lineItemId": options.lineItemId,
                    "count"     : options.lineItemCount,
                    "clientTime": new Date().getTime()
                },
                "controller": "order",
                "action"    : "setLineItemCount"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        deleteLineItemByLineItemId: function (options) {
            var out = {
                "params"    : {
                    "lineItemId": options.lineItemId
                },
                "controller": "order",
                "action"    : "deleteLineItemByLineItemId"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 非公开，食客评论一单
         * @param options
         */
        setOrderReview: function (options) {
            var out = {
                "params"    : {
                    "orderId": options.orderId,
                    "review" : options.review
                },
                "controller": "order",
                "action"    : "setOrderReview"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 获得一个 LineItem
         */
        getLineItemById: function (lId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "LId": lId
                },
                "controller": "order",
                "action"    : "getLineItemById"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 按照订单状态搜索订单里的条目
         */
        getLineItemByStatusList: function (status, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "Status": status
                },
                "controller": "order",
                "action"    : "getLineItemByStatusList"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        getPrepayLineItemList: function (options) {
            var out = {
                "params"    : {
                    "orderId": options.orderId
                },
                "controller": "order",
                "action"    : "getPrepayLineItemList"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 按照订单ID搜索订单里的条目
         */
        getLineItemByOIdList: function (oId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "OId": oId
                },
                "controller": "order",
                "action"    : "getLineItemByOIdList"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 按照订单ID获得订单里的数量
         */
        getLineItemNumByOrderId: function (options) {
            var out = {
                "params"    : {
                    "OrderId": options.OrderId
                },
                "controller": "order",
                "action"    : "getLineItemNumByOrderId"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 结账。修改 。Order 和 LienItem 的 state 设置 CLOSE ， status 改成 billed 。
         * 修改时判断 lineItem 的 status 不是 closed
         * Order status 是 closed 不可以结账,LineItem 的 status 改成 closed
         */
        bill: function (oId, tokenIdList, memberId, remark, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "OId"        : oId,
                    "tokenIdList": tokenIdList,
                    "memberId"   : memberId,
                    "remark"     : remark
                },
                "controller": "order",
                "action"    : "bill"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 预结账
         * @param options
         */
        preBill: function (options) {
            var out = {
                "params"    : {
                    "orderId": options.orderId
                },
                "controller": "order",
                "action"    : "preBill"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getNoSettlementShiftTurnoverOrderList: function (options) {
            var out = {
                "params"    : {},
                "controller": "order",
                "action"    : "getNoSettlementShiftTurnoverOrderList"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getNoSettlementShiftTurnoverOrderListByTableId: function (options) {
            var out = {
                "params"    : {
                    "tableId": options.tableId
                },
                "controller": "order",
                "action"    : "getNoSettlementShiftTurnoverOrderListByTableId"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 反结账
         * @param options
         */
        backtrackBill: function (options) {
            var out = {
                "params"    : {
                    "orderId": options.orderId,
                    "reason" : options.reason
                },
                "controller": "order",
                "action"    : "backtrackBill"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 打印结账的小票
         */
        billOrderPrinter: function (orderId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "orderId": orderId
                },
                "controller": "order",
                "action"    : "billOrderPrinter"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 打印订单的菜品
         */
        orderLineItemPrinter: function (orderId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "orderId": orderId
                },
                "controller": "order",
                "action"    : "orderLineItemPrinter"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        confirmationCpReachTable: function (options) {
            var out = {
                "params"    : {
                    "lineItemId": options.lineItemId
                },
                "controller": "order",
                "action"    : "confirmationCpReachTable"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        turnOverConfirmationCpReachTable: function (options) {
            var out = {
                "params"    : {
                    "lineItemId": options.lineItemId
                },
                "controller": "order",
                "action"    : "turnOverConfirmationCpReachTable"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getStartProductionTable: function (options) {
            var out = {
                "params"    : {},
                "controller": "order",
                "action"    : "getStartProductionTable"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 短信验证订单
         */
        orderSmsValid: function (oId, mobile, lineItem, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "OId"     : oId,
                    "Mobile"  : mobile,
                    "LineItem": lineItem
                },
                "controller": "order",
                "action"    : "orderSmsValid"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 验证订单
         */
        validOrder: function (oId, capt, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "OId" : oId,
                    "capt": capt
                },
                "controller": "order",
                "action"    : "validOrder"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 发送会员结账短信
         */
        //sendMemberBillSMS: function (oId, mid, successFunction, errorFunction, completeFunction) {
        //    var out = {
        //        "params"    : {
        //            "OId": oId,
        //            "MId": mid
        //        },
        //        "controller": "order",
        //        "action"    : "sendMemberBillSMS"
        //    };
        //    request(out, successFunction, errorFunction, completeFunction);
        //},
        //
        ///**
        // * 验证会员消费短信
        // */
        //memberBillSMS: function (oId, mid, capt, successFunction, errorFunction, completeFunction) {
        //    var out = {
        //        "params"    : {
        //            "OId" : oId,
        //            "MId" : mid,
        //            "capt": capt
        //        },
        //        "controller": "order",
        //        "action"    : "memberBillSMS"
        //    };
        //    request(out, successFunction, errorFunction, completeFunction);
        //},

        /**
         * 过的人均消费
         */
        perCapitaConsumptionByDateRange: function (start, end, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "start": start,
                    "end"  : end
                },
                "controller": "order",
                "action"    : "perCapitaConsumptionByDateRange"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 一段时间的人均日消费列表
         * @param options
         */
        dailyPerCapitaConsumption: function (options) {
            var out = {
                "params"    : {
                    "start": options.start,
                    "end"  : options.end
                },
                "controller": "order",
                "action"    : "dailyPerCapitaConsumption"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 翻台率
         */
        turnOver: function (start, end, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "start": start,
                    "end"  : end
                },
                "controller": "order",
                "action"    : "turnOver"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 获得预订订单历史
         * @param options
         */
        getPreOrderHistory: function (options) {
            var out = {
                "params"    : {
                    "ezcMemberId": options.ezcMemberId
                },
                "controller": "order",
                "action"    : "getPreOrderHistory"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 获得外卖订单
         * @param options
         */
        getTakeawayHistory: function (options) {
            var out = {
                "params"    : {
                    "ezcMemberId": options.ezcMemberId
                },
                "controller": "order",
                "action"    : "getTakeawayHistory"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getMemberNormalOrderHistory: function (options) {
            var out = {
                "params"    : {
                    "ezcMemberId": options.ezcMemberId
                },
                "controller": "order",
                "action"    : "getMemberNormalOrderHistory"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getMemberOrderBilled: function (options) {
            var out = {
                "params"    : {
                    "ezcMemberId": options.ezcMemberId
                },
                "controller": "order",
                "action"    : "getMemberOrderBilled"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 获得会员用过的地址
         * @param options
         */
        getEzcMemberHistoryAddress: function (options) {
            var out = {
                "params"    : {
                    "ezcMemberId": options.ezcMemberId
                },
                "controller": "member",
                "action"    : "getEzcMemberHistoryAddress"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getWeiXinUserByOpenId: function (options) {
            var out = {
                "params"    : {
                    "openId": options.openId
                },
                "controller": "member",
                "action"    : "getWeiXinUserByOpenId"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 记录优惠卷到订单
         * @param options
         */
        setCustomerSelectToken: function (options) {
            var out = {
                "params"    : {
                    "orderId": options.orderId,
                    "tokenId": options.tokenId
                },
                "controller": "order",
                "action"    : "setCustomerSelectToken"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 拒接订单
         * @param options
         */
        rejectOrder: function (options) {
            var out = {
                "params"    : {
                    "orderId"     : options.orderId,
                    "rejectReason": options.rejectReason
                },
                "controller": "order",
                "action"    : "rejectOrder"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        order_addFav: function (options) {
            var out = {
                "params"    : {
                    "cpId"   : options.cpId,
                    "orderId": options.orderId
                },
                "controller": "order",
                "action"    : "addFav"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        order_getFav: function (options) {
            var out = {
                "params"    : {
                    "orderId": options.orderId
                },
                "controller": "order",
                "action"    : "getFav"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        order_delFav: function (options) {
            var out = {
                "params"    : {
                    "cpId"   : options.cpId,
                    "orderId": options.orderId
                },
                "controller": "order",
                "action"    : "delFav"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 将会员电话写入订单
         * @param options
         */
        setOrderMemberMobile: function (options) {
            var out = {
                "params"    : {
                    "orderId"     : options.orderId,
                    "memberMobile": options.memberMobile
                },
                "controller": "order",
                "action"    : "setOrderMemberMobile"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        unsetOrderMemberMobile: function (options) {
            var out = {
                "params"    : {
                    "orderId": options.orderId
                },
                "controller": "order",
                "action"    : "unsetOrderMemberMobile"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },


        //获得一个店员的交班的收支详情
        getUserIdBalanceOfPaymentByDate: function (options) {
            var out = {
                "params"    : {
                    "userId": options.userId,
                    "start" : options.start,
                    "end"   : options.end
                },
                "controller": "login",
                "action"    : "getUserIdBalanceOfPaymentByDate"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        //获得店内所有为处理的任务个数
        getAllTaskCount: function (options) {
            var out = {
                "params"    : {},
                "controller": "login",
                "action"    : "getAllTaskCount"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /***********************************
         * 桌台种类操作
         ***********************************/
        /**
         * 新建桌台种类
         * @param options
         */
        newTableClass: function (options) {
            var out = {
                "params"    : {
                    "name": options.name,
                    "cap" : options.cap
                },
                "controller": "tableClass",
                "action"    : "newTableClass"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 删除桌台种类
         * @param options
         */
        deleteTableClass: function (options) {
            var out = {
                "params"    : {
                    "tableClassId": options.tableClassId
                },
                "controller": "tableClass",
                "action"    : "deleteTableClass"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 获得一个桌台种类
         * @param options
         */
        getTableClassByTableClassId: function (options) {
            var out = {
                "params"    : {
                    "tableClassId": options.tableClassId
                },
                "controller": "tableClass",
                "action"    : "getTableClassByTableClassId"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 获取桌台分类列表
         * @param options
         */
        getTableClassList: function (options) {
            var out = {
                "params"    : {},
                "controller": "tableClass",
                "action"    : "getTableClassList"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 修改桌台种类名字
         * @param options
         */
        setTableNameByTableClassId: function (options) {
            var out = {
                "params"    : {
                    "tableClassId": options.tableClassId,
                    "name"        : options.name
                },
                "controller": "tableClass",
                "action"    : "setTableNameByTableClassId"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 修改桌台种类人数
         * @param options
         */
        setTableCapByTableClassId: function (options) {
            var out = {
                "params"    : {
                    "tableClassId": options.tableClassId,
                    "cap"         : options.cap
                },
                "controller": "tableClass",
                "action"    : "setTableCapByTableClassId"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /***********************************
         * 桌的操作
         ***********************************/

        /**
         * 添加桌台
         */
        addTable: function (table, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "label"   : table.label,//桌号
                    "tableCap": table.tableCap//人数
                },
                "controller": "table",
                "action"    : "addTable"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 删除桌台
         */
        deleteTable: function (tId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "TId": tId
                },
                "controller": "table",
                "action"    : "deleteTable"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 读取一个桌台
         */
        getTableById: function (tId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "TId": tId
                },
                "controller": "table",
                "action"    : "getTableById"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 读取一个桌台
         */
        getTableByLabel: function (label, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "label": label
                },
                "controller": "table",
                "action"    : "getTableByLabel"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 读取所有桌台
         */
        getTableList: function (successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {},
                "controller": "table",
                "action"    : "getTableList"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },


        /**
         * 获得店家所有桌台二维码
         */
        getTableListByRid: function (options) {
            var out = {
                "params"    : {},
                "controller": "table",
                "action"    : "getTableListByRid"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },


        setTableCap: function (tId, tableCap, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "TId"     : tId,
                    "tableCap": tableCap
                },
                "controller": "table",
                "action"    : "setTableCap"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 修改桌台状态
         */
        setTableStatus: function (tId, status, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "TId"   : tId,
                    "Status": status
                },
                "controller": "table",
                "action"    : "setTableStatus"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 修改坐台类型
         * @param options
         */
        setTableTableClassId: function (options) {
            var out = {
                "params"    : {
                    "tableId"     : options.tableId,
                    "tableClassId": options.tableClassId
                },
                "controller": "table",
                "action"    : "setTableTableClassId"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        setTableHomePageLogo: function (options) {
            ajaxFileUpload(options.imageId, function (data) {
                var out = {
                    "params"    : {
                        "tableId": options.tableId,
                        "imageId": data.data.imageId
                    },
                    "controller": "table",
                    "action"    : "setTableHomePageLogo"
                };
                request(out, options.successFunction, options.errorFunction, options.completeFunction);
            });
        },

        setTableHomePageLogoByBase64: function (options) {
            var out = {
                "params"    : {
                    "tableId"          : options.tableId,
                    "base64ImageString": options.base64ImageString
                },
                "controller": "table",
                "action"    : "setTableHomePageLogoByBase64"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getTableHomePageLogo: function (options) {
            var out = {
                "params"    : {
                    "tableId": options.tableId
                },
                "controller": "table",
                "action"    : "getTableHomePageLogoUrl"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 按照状态搜索桌台
         */
        getTableListByStatus: function (status, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "Status": status
                },
                "controller": "table",
                "action"    : "getTableListByStatus"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 通过桌台种类获得桌台
         * @param options
         */
        getTableListByTableClassId: function (options) {
            var out = {
                "params"    : {
                    "tableClassId": options.tableClassId
                },
                "controller": "table",
                "action"    : "getTableListByTableClassId"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 强制释放桌台
         */
        freeTable: function (tId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "TId": tId
                },
                "controller": "table",
                "action"    : "freeTable"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 换桌
         */
        exChangeTable: function (oId, newTId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "OId"   : oId,
                    "newTId": newTId
                },
                "controller": "table",
                "action"    : "exChangeTable"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 用户预订订单落桌
         * @param options
         */
        pushPreOrderToTable: function (options) {
            var out = {
                "params"    : {
                    "OId"     : options.OId,
                    "TId"     : options.TId,
                    "capt"    : options.capt,
                    "UId"     : options.UId,
                    "NickName": options.NickName
                },
                "controller": "table",
                "action"    : "pushPreOrderToTable"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        pushReserveOrderToTable: function (options) {
            var out = {
                "params"    : {
                    "orderId": options.orderId,
                    "tableId": options.tableId
                },
                "controller": "table",
                "action"    : "pushReserveOrderToTable"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        //已落桌的预定订单清除桌台关系
        tableToReserveOrder: function (options) {
            var out = {
                "params"    : {
                    "orderId": options.orderId,
                    "tableId": options.tableId
                },
                "controller": "table",
                "action"    : "tableToReserveOrder"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },


        table_addFav: function (options) {
            var out = {
                "params"    : {
                    "cpId"   : options.cId,
                    "tableId": options.tId
                },
                "controller": "table",
                "action"    : "addFav"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        table_getFav: function (options) {
            var out = {
                "params"    : {
                    "tableId": options.tId
                },
                "controller": "table",
                "action"    : "getFav"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        table_delFav: function (options) {
            var out = {
                "params"    : {
                    "cpId"   : options.cId,
                    "tableId": options.tId
                },
                "controller": "table",
                "action"    : "delFav"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        addGuestToTable: function (options) {
            var out = {
                "params"    : {
                    "tableId" : options.tableId,
                    "type"    : options.type,
                    "NickName": options.NickName,
                    "openId"  : options.openId
                },
                "controller": "table",
                "action"    : "addGuestToTable"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /***********************************
         * 管理用户组
         ***********************************/

        /**
         * 初始化用户分组
         */
        initLoginGroup: function (successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {},
                "controller": "loginGroupAuth",
                "action"    : "initLoginGroup"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        newLoginGroup: function (loginGroup, permissionGrade, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "loginGroup"     : loginGroup,
                    "permissionGrade": permissionGrade
                },
                "controller": "loginGroupAuth",
                "action"    : "newLoginGroup"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        setLoginGroupPermissionGradeByName: function (loginGroup, permissionGrade, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "loginGroup"     : loginGroup,
                    "permissionGrade": permissionGrade
                },
                "controller": "loginGroupAuth",
                "action"    : "setLoginGroupPermissionGradeByName"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        getLoginGroupAuthList: function (successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {},
                "controller": "loginGroupAuth",
                "action"    : "getLoginGroupAuthList"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /***********************************
         * 登入的操作（店家自己管理）
         ***********************************/

        /**
         * 授权 检测
         */
        signIn: function (user, pwd, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "User"    : user,
                    "PassWord": pwd
                },
                "controller": "login",
                "action"    : "signIn"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        exitLogout: function (successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {},
                "controller": "login",
                "action"    : "exitLogout"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 添加用户
         */
        addUser: function (user, pwd, group, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "User"    : user,
                    "PassWord": pwd,
                    "Group"   : group
                },
                "controller": "login",
                "action"    : "addUser"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 删除用户
         */
        deleteUser: function (userId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "UserId": userId
                },
                "controller": "login",
                "action"    : "deleteUser"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 修改用户名字
         */
        setUserName: function (userId, name, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "UserId": userId,
                    "name"  : name
                },
                "controller": "login",
                "action"    : "setUserName"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 修改密码
         */
        setUserPassWord: function (userId, pass, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "UserId"  : userId,
                    "PassWord": pass
                },
                "controller": "login",
                "action"    : "setUserPassWord"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 修改用户组
         */
        setUserGroup: function (userId, group, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "UserId": userId,
                    "Group" : group
                },
                "controller": "login",
                "action"    : "setUserGroup"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 获得所有用户
         */
        getUserList: function (successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {},
                "controller": "login",
                "action"    : "getUserList"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        showShiftTurnoverInfo: function (options) {
            var out = {
                "params"    : {},
                "controller": "login",
                "action"    : "showShiftTurnoverInfo"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        shiftTurnover: function (options) {
            var out = {
                "params"    : {
                    'remark': options.remark
                },
                "controller": "login",
                "action"    : "shiftTurnover"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 获得没有结算的班
         * @param options
         */
        getNoSettlementShiftTurnoverList: function (options) {
            var out = {
                "params"    : {},
                "controller": "login",
                "action"    : "getNoSettlementShiftTurnoverList"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        confirmSettlementShiftTurnover: function (options) {
            var out = {
                "params"    : {
                    'shiftTurnoverId': options.shiftTurnoverId,
                    'userId'         : options.userId,
                    'pass'           : options.pass
                },
                "controller": "login",
                "action"    : "confirmSettlementShiftTurnover"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        shiftTurnoverHistory: function (options) {
            var out = {
                "params"    : {
                    "userId": options.userId
                },
                "controller": "login",
                "action"    : "shiftTurnoverHistory"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        shiftTurnoverHistoryByDateRange: function (options) {
            var out = {
                "params"    : {
                    "userId": options.userId,
                    "start" : options.start,
                    "end"   : options.end
                },
                "controller": "login",
                "action"    : "shiftTurnoverHistoryByDateRange"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /***********************************
         * 店员验证
         ***********************************/

        setPINByUserId: function (options) {
            var out = {
                "params"    : {
                    "userId": options.userId,
                    "pin"   : options.pin
                },
                "controller": "login",
                "action"    : "setPINByUserId"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 验证店员 PIN
         * @param pId
         * @param successFunction
         * @param errorFunction
         * @param completeFunction
         *
         * @deprecated
         */
        checkPId: function (pId, successFunction, errorFunction, completeFunction) {
            var options = {};
            options.pin = pId;
            options.successFunction = successFunction;
            options.errorFunction = errorFunction;
            options.completeFunction = completeFunction;

            OrderingSystem.checkClerkPIN(options);
        },

        /**
         * 验证店员 PIN
         * @param options
         */
        checkClerkPIN: function (options) {
            var out = {
                "params"    : {
                    "pin": options.pin
                },
                "controller": "login",
                "action"    : "checkClerkPIN"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /***********************************
         * 会员的操作
         ***********************************/

        addMember: function (member, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "memberName"  : member.memberName,//会员名字
                    "memberMobile": member.memberMobile,//会员的电话
                    "level"       : member.level,//会员等级 A B C
                    "memberMemo"  : member.memberMemo,//备注
                    "channel"     : member.channel,//会员注册渠道
                    "number"      : member.number,//会员号码
                },
                "controller": "member",
                "action"    : "addMember"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        sendAddEzcMemberAndOpenIdSMS: function (options) {

            var out = {
                "params"    : {
                    "memberMobile": options.memberMobile,//会员的电话
                    "openId"      : options.openId
                },
                "controller": "member",
                "action"    : "sendAddEzcMemberAndOpenIdSMS"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        regEzcMemberToStoreMember: function (options) {
            var out = {
                "params"    : {
                    "mobile": options.mobile,//会员的电话
                },
                "controller": "member",
                "action"    : "regEzcMemberToStoreMember"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        verificationAddEzcMemberAndOpenIdSMS: function (options) {
            var out = {
                "params"    : {
                    "capt"      : options.capt,
                    "openId"    : options.openId,
                    "memberName": options.memberName//选填
                },
                "controller": "member",
                "action"    : "verificationAddEzcMemberAndOpenIdSMS"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        sendAddEzcMemberSMS: function (options) {
            var out = {
                "params"    : {
                    "memberMobile": options.memberMobile//会员的电话
                },
                "controller": "member",
                "action"    : "sendAddEzcMemberSMS"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        verificationAddEzcMemberSMS: function (options) {
            var out = {
                "params"    : {
                    "capt"      : options.capt,
                    "memberName": options.memberName//选填
                },
                "controller": "member",
                "action"    : "verificationAddEzcMemberSMS"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         *
         * @param mId
         * @param successFunction
         * @param errorFunction
         * @param completeFunction
         * @deprecated
         */
        deleteMember: function (mId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "MId": mId//备注
                },
                "controller": "member",
                "action"    : "deleteMember"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        setMemberName: function (mId, name, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "MId" : mId,
                    "Name": name
                },
                "controller": "member",
                "action"    : "setMemberName"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        setMemberPhone: function (mId, phone, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "MId"  : mId,
                    "Phone": phone
                },
                "controller": "member",
                "action"    : "setMemberPhone"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        setMemberNum: function (mId, number, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "MId"   : mId,
                    "number": number
                },
                "controller": "member",
                "action"    : "setMemberNum"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        setMemberLevel: function (mId, level, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "MId"  : mId,
                    "Level": level
                },
                "controller": "member",
                "action"    : "setMemberLevel"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        setMemberMemo: function (mId, memo, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "MId" : mId,
                    "Memo": memo
                },
                "controller": "member",
                "action"    : "setMemberMemo"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        setMemberStatus: function (mId, status, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "MId"   : mId,
                    "Status": status
                },
                "controller": "member",
                "action"    : "setMemberStatus"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        getMemberById: function (mId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "MId": mId
                },
                "controller": "member",
                "action"    : "getMemberById"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 通过电话查询会员
         * @param mobile
         * @param successFunction
         * @param errorFunction
         * @param completeFunction
         */
        getMemberByMobile: function (mobile, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "Mobile": mobile
                },
                "controller": "member",
                "action"    : "getMemberByMobile"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 获得云易会员
         * @param options
         */
        getEZCMemberByMobile: function (options) {
            var out = {
                "params"    : {
                    "mobile": options.mobile
                },
                "controller": "member",
                "action"    : "getEZCMemberByMobile"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getMemberByName: function (name, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "Name": name
                },
                "controller": "member",
                "action"    : "getMemberByName"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        getMemberList: function (successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {},
                "controller": "member",
                "action"    : "getMemberList"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        getMemberWeiXinUid: function (options) {
            var out = {
                "params"    : {
                    "UId": options.uid
                },
                "controller": "member",
                "action"    : "getMemberWeiXinUid"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 获得云易会员
         * @param options
         */
        getEzcMemberWeiXinOpenId: function (options) {
            var out = {
                "params"    : {
                    "openId": options.openId
                },
                "controller": "member",
                "action"    : "getEzcMemberWeiXinOpenId"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 获得云易会员
         * @param options
         */
        getEZCMemberList: function (options) {
            var out = {
                "params"    : {},
                "controller": "member",
                "action"    : "getEZCMemberList"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 会员充值
         */
        memberCharge: function (mId, amount, point, paymentMethod, memo, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "memberId"     : mId,
                    "Amount"       : amount,
                    "point"        : point,
                    "paymentMethod": paymentMethod,
                    "Memo"         : memo
                },
                "controller": "member",
                "action"    : "memberCharge"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        memberSpend: function (options) {
            var out = {
                "params"    : {
                    "memberId": options.mId,
                    "orderId" : options.oId,
                    "money"   : options.money,
                    "memo"    : options.memo
                },
                "controller": "member",
                "action"    : "memberSpend"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        tagWrongMemberTransByMemberTransId: function (options) {
            var out = {
                "params"    : {
                    "transId"    : options.transId,
                    "wrongReason": options.wrongReason
                },
                "controller": "member",
                "action"    : "tagWrongMemberTransByMemberTransId"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 查询一个会员余额的
         * @param mId
         * @param successFunction
         * @param errorFunction
         * @param completeFunction
         */
        getMemberAccountAmount: function (mId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "memberId": mId
                },
                "controller": "member",
                "action"    : "getMemberAccountBalance"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 获得一个订单，每个会员支付的流水
         */
        getMemberSpendTransByOrderId: function (options) {
            var out = {
                "params"    : {
                    "orderId": options.orderId
                },
                "controller": "member",
                "action"    : "getMemberSpendAnOrderPayTransByOrderId"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getMemberTransByTransId: function (options) {
            var out = {
                "params"    : {
                    "transId": options.transId
                },
                "controller": "member",
                "action"    : "getMemberTransByTransId"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getMemberAccountTrans: function (mId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "memberId": mId
                },
                "controller": "member",
                "action"    : "getMemberAccountTrans"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        printerMemberAccountTrans: function (options) {
            var out = {
                "params"    : {
                    "memberId": options.memberId
                },
                "controller": "member",
                "action"    : "printerMemberAccountTrans"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getMemberAccountAllAmount: function (successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {},
                "controller": "member",
                "action"    : "getMemberAccountAllAmount"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 会员短信激活发送验证码
         */
        sendVaildMemberSMS: function (mId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "MId": mId
                },
                "controller": "member",
                "action"    : "sendVaildMemberSMS"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 验证激活会员短信
         */
        vaildMemberSMS: function (mId, capt, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "MId" : mId,
                    "capt": capt
                },
                "controller": "member",
                "action"    : "vaildMemberSMS"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        addMemberToken: function (options) {
            var out = {
                "params"    : {
                    "memberId": options.memberId,
                    "tokenId" : options.tokenId
                },
                "controller": "member",
                "action"    : "addMemberToken"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        deleteMemberToken: function (options) {
            var out = {
                "params"    : {
                    "memberId": options.memberId,
                    "tokenId" : options.tokenId
                },
                "controller": "member",
                "action"    : "deleteMemberToken"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        addEzcMemberToken: function (options) {
            var out = {
                "params"    : {
                    "ezcMemberId": options.ezcMemberId,
                    "tokenId"    : options.tokenId
                },
                "controller": "member",
                "action"    : "addEzcMemberToken"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 删除会员优惠卷收藏
         * @param options
         */
        deleteEzcMemberToken: function (options) {
            var out = {
                "params"    : {
                    "ezcMemberId": options.ezcMemberId,
                    "tokenId"    : options.tokenId
                },
                "controller": "member",
                "action"    : "deleteEzcMemberToken"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getMemberInfoList: function (options) {
            var out = {
                "params"    : {},
                "controller": "member",
                "action"    : "getMemberInfoList"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        sendMobileBindWeiXinSMS: function (options) {
            var out = {
                "params"    : {
                    "openId": options.openId,
                    "mobile": options.mobile
                },
                "controller": "member",
                "action"    : "sendMobileBindWeiXinSMS"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        weiXinMobileBind: function (options) {
            var out = {
                "params"    : {
                    "rId"        : options.rId,
                    "openId"     : options.openId,
                    "capt"       : options.capt,
                    "ezcMemberId": options.ezcMemberId
                },
                "controller": "member",
                "action"    : "weiXinMobileBind"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        weiXinBind: function (options) {
            var out = {
                "params"    : {
                    "rId"   : options.rId,
                    "openId": options.openId,
                    "mobile": options.mobile
                },
                "controller": "member",
                "action"    : "weiXinBind"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 领取店家会员卡
         * @param options
         */
        restaurantAddMember: function (options) {
            var out = {
                "params"    : {
                    "mobile": options.mobile
                },
                "controller": "member",
                "action"    : "restaurantAddMember"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 获得会员等级列表
         * @param options
         */
        getMemberLevelList: function (options) {
            var out = {
                "params"    : {},
                "controller": "member",
                "action"    : "getMemberLevelList"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        setMemberLevelNameByLevel: function (options) {
            var out = {
                "params"    : {
                    'level': options.level,
                    'name' : options.name
                },
                "controller": "member",
                "action"    : "setMemberLevelNameByLevel"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        availableMemberLevelList: function (options) {
            var out = {
                "params"    : {},
                "controller": "member",
                "action"    : "availableMemberLevelList"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 搜索会员
         * @param options
         */
        searchMember: function (options) {
            var out = {
                "params"    : {
                    "keyword": options.keyword
                },
                "controller": "member",
                "action"    : "searchMember"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /***********************************
         * 店家服务的操作
         ***********************************/

        /**
         * 创建新的服务类别
         */
        newServiceClass: function (eventName, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "eventName": eventName
                },
                "controller": "service",
                "action"    : "newServiceClass"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        deleteServiceClassByServiceClassId: function (options) {
            var out = {
                "params"    : {
                    "serviceClassId": options.serviceClassId
                },
                "controller": "service",
                "action"    : "deleteServiceClassByServiceClassId"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        setServiceClassName: function (scId, eventName, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "SCId"     : scId,
                    "eventName": eventName
                },
                "controller": "service",
                "action"    : "setServiceClassName"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 设置这个服务是可用的
         */
        scActive: function (scId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "SCId": scId
                },
                "controller": "service",
                "action"    : "scActive"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 设置这个服务是不可用的
         */
        scDeactive: function (scId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "SCId": scId
                },
                "controller": "service",
                "action"    : "scDeactive"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 查询可用服务 修改 设立写死了。可以改成参数可选
         */
        getServiceClassActiveList: function (successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "status": "active"
                },
                "controller": "service",
                "action"    : "getServiceClassByStatusList"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 获得服务类别列表
         */
        getServiceClassList: function (successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {},
                "controller": "service",
                "action"    : "getServiceClassList"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 用服务种类新建服务请求
         */
        newServiceLogBySCId: function (obj, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : obj,
                "controller": "service",
                "action"    : "newServiceLogBySCId"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 用 detail 新建服务请求
         */
        newServiceLogByDetail: function (obj, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : obj,
                "controller": "service",
                "action"    : "newServiceLogByDetail"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 转交服务
         * @param options
         */
        deliverService: function (options) {
            var out = {
                "params"    : {
                    "serviceId": options.serviceId,
                    "clerkId"  : options.clerkId
                },
                "controller": "service",
                "action"    : "deliverService"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 等候
         * @param options
         */
        waitService: function (options) {
            var out = {
                "params"    : {
                    "serviceId": options.serviceId
                },
                "controller": "service",
                "action"    : "waitService"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 响应服务呼叫
         *
         * @deprecated
         */
        respondService: function (sId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "SId": sId
                },
                "controller": "service",
                "action"    : "respondService"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        completeService: function (sId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "SId": sId
                },
                "controller": "service",
                "action"    : "completeService"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 呼叫服务——用户留言
         * @param options
         */
        userAddServiceGuestbook: function (options) {
            var out = {
                "params"    : {
                    "serviceId": options.serviceId,
                    "openId"   : options.openId,
                    "NickName" : options.NickName,
                    "content"  : options.content
                },
                "controller": "service",
                "action"    : "userAddServiceGuestbook"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 呼叫服务——用户留言
         * @param options
         */
        waiterAddServiceGuestbook: function (options) {
            var out = {
                "params"    : {
                    "serviceId": options.serviceId,
                    "content"  : options.content
                },
                "controller": "service",
                "action"    : "waiterAddServiceGuestbook"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 获得未处理的服务呼叫
         */
        getServiceActiveList: function (successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {},
                "controller": "service",
                "action"    : "getServiceActiveList"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 获得一条服务详情
         */
        getServiceInfoById: function (options) {
            var out = {
                "params"    : {
                    "SCId": options.SCId
                },
                "controller": "service",
                "action"    : "getServiceInfoById"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 锁定一条服务详情
         */

        catchOneServiceLog: function (options) {
            var out = {
                "params"    : {
                    "serviceId": options.SCId
                },
                "controller": "service",
                "action"    : "catchOneServiceLog"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 获得除未完成状态的服务  getMyNotCompleteServiceList 包括（new、deliver、 wait、responded ）
         */
        getMyNotCompleteServiceList: function (options) {
            var out = {
                "params"    : {},
                "controller": "service",
                "action"    : "getMyNotCompleteServiceList"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 获得登入后自己响应的服务
         * @param options
         */
        getLoginAfterwardsRespondedService: function (options) {
            var out = {
                "params"    : {},
                "controller": "service",
                "action"    : "getLoginAfterwardsRespondedService"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 获得登入后自己完成的服务
         * @param options
         */
        getLoginAfterwardsCompleteService: function (options) {
            var out = {
                "params"    : {},
                "controller": "service",
                "action"    : "getLoginAfterwardsCompleteService"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 根据日期获得用户特定的服务状态列表
         * @param options
         */
        getUserCheckServiceByStatusOrDay: function (options) {
            var out = {
                "params"    : {
                    "startDay"  : options.startDay,
                    "endDay"    : options.endDay,
                    "StatusType": options.StatusType
                },
                "controller": "service",
                "action"    : "getUserCheckServiceByStatusOrDay"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 获得一类服务呼叫
         */
        getServiceListBySC: function (scId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "SCId": scId
                },
                "controller": "service",
                "action"    : "getServiceListBySC"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 获得一单的服务请求
         * @param options
         */
        getServiceListByOrderId: function (options) {
            var out = {
                "params"    : {
                    "orderId": options.orderId
                },
                "controller": "service",
                "action"    : "getServiceListByOrderId"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 根据桌台id和订单id获得呼叫的全部服务
         * @param options
         */
        getServiceListByTableIdAndOrderId: function (options) {
            var out = {
                "params"    : {
                    "tableId": options.tableId,
                    "orderId": options.orderId
                },
                "controller": "service",
                "action"    : "getServiceListByTableIdAndOrderId"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 获得一个桌台呼叫过的服务
         * @param options
         */
        getServiceHistoryByTableId: function (options) {
            var out = {
                "params"    : {
                    "tableId": options.tableId,
                    "orderId": options.orderId
                },
                "controller": "service",
                "action"    : "getServiceHistoryByTableId"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 获得全部服务呼叫
         */
        getServiceList: function (successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {},
                "controller": "service",
                "action"    : "getServiceList"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 获得一种服务的使用次数
         */
        statServiceEmployAmountBySCId: function (scId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "SCId": scId
                },
                "controller": "service",
                "action"    : "statServiceEmployAmountBySCId"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        statServiceEmployAmountListBySCId: function (successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {},
                "controller": "service",
                "action"    : "statServiceEmployAmountListBySCId"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /***********************************
         * 优惠卷的操作
         ***********************************/

        /**
         * 新建优惠卷
         */
        newToken: function (token, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : token,
                "controller": "token",
                "action"    : "newToken"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 修改优惠卷状态
         */
        setTokenStatusByTokenId: function (tokenId, status, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "tokenId": tokenId,
                    "status" : status
                },
                "controller": "token",
                "action"    : "setTokenStatusByTokenId"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 上架优惠卷
         */
        actionToken: function (tokenId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "tokenId": tokenId,
                    "status" : "active"
                },
                "controller": "token",
                "action"    : "setTokenStatusByTokenId"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 优惠卷下架
         */
        deactionToken: function (tokenId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "tokenId": tokenId,
                    "status" : "deactive"
                },
                "controller": "token",
                "action"    : "setTokenStatusByTokenId"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 根据 id 获得优惠卷
         */
        getTokenByTokenId: function (tokenId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "tokenId": tokenId
                },
                "controller": "token",
                "action"    : "getTokenByTokenId"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 根据优惠卷状态获得
         */
        getTokenByStatus: function (status, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "status": status
                },
                "controller": "token",
                "action"    : "getTokenByStatus"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        getActiveToken: function (options) {
            var out = {
                "params"    : {
                    "status": "active"
                },
                "controller": "token",
                "action"    : "getTokenByStatus"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 获得一种优惠卷的流水
         */
        getTokenTransListByTokenId: function (tokenId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "tokenId": tokenId
                },
                "controller": "token",
                "action"    : "getTokenTransListByTokenId"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        getTokenTransListByMemberIdAndRulesType: function (options) {
            var out = {
                "params"    : {
                    "memberId" : options.memberId,
                    "rulesType": options.rulesType
                },
                "controller": "token",
                "action"    : "getTokenTransListByMemberIdAndRulesType"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 获得优惠卷列表
         */
        getTokenList: function (successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {},
                "controller": "token",
                "action"    : "getTokenList"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 获得所有优惠卷流水
         */
        getTokenTransList: function (successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {},
                "controller": "token",
                "action"    : "getTokenTransList"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 获得一种优惠卷节省的钱
         */
        getSaveMoney: function (tokenId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "tokenId": tokenId
                },
                "controller": "token",
                "action"    : "getSaveMoney"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 获得优惠卷使用次数
         * @param options
         */
        getTokenInfo: function (options) {
            var out = {
                "params"    : {
                    "tokenId": options.tokenId
                },
                "controller": "token",
                "action"    : "getTokenInfo"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 获得优惠卷使详细信息列表
         * @param options
         */
        getTokenInfoList: function (options) {
            var out = {
                "params"    : {},
                "controller": "token",
                "action"    : "getTokenInfoList"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 获得优惠卷
         * @param options
         */
        getEZCMemberToken: function (options) {
            var out = {
                "params"    : {
                    "memberId": options.memberId
                },
                "controller": "token",
                "action"    : "getEZCMemberToken"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /***********************************
         * 打印机的操作
         ***********************************/

        /**
         * 添加打印机
         */
        addPrinter: function (options) {
            var out = {
                "params"    : {
                    "name"          : options.name,//店家给打印机起的名字
                    "model"         : options.model,//型号
                    "type"          : options.type,//打印机类型
                    "printerAddress": options.printerAddress,//打印机打印命令地址 ip:port 的
                    "printerInquire": options.printerInquire//打印机打印命令地址 ip:port 的
                },
                "controller": "printer",
                "action"    : "addPrinter"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 根据名字获得打印机
         * @param options
         */
        getPrinterByName: function (options) {
            var out = {
                "params"    : {
                    "name": options.name//店家给打印机起的名字
                },
                "controller": "printer",
                "action"    : "getPrinterByName"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getPrinterByPrinterId: function (options) {
            var out = {
                "params"    : {
                    "printerId": options.printerId
                },
                "controller": "printer",
                "action"    : "getPrinterByPrinterId"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 获得打印机列表
         */
        getPrinterList: function (options) {
            var out = {
                "params"    : {},
                "controller": "printer",
                "action"    : "getPrinterList"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        deletePrinter: function (options) {
            var out = {
                "params"    : {
                    "printerId": options.printerId
                },
                "controller": "printer",
                "action"    : "deletePrinter"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 修改打印机的名字
         */
        setPrinterName: function (options) {
            var out = {
                "params"    : {
                    "printerId": options.printerId,
                    "name"     : options.name
                },
                "controller": "printer",
                "action"    : "setPrinterName"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 修改打印机型号
         * @param options
         */
        setPrinterModel: function (options) {
            var out = {
                "params"    : {
                    "printerId": options.printerId,
                    "model"    : options.model
                },
                "controller": "printer",
                "action"    : "setPrinterModel"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 修改打印机打印命令地址
         */
        setPrinterPrinterAddress: function (options) {
            var out = {
                "params"    : {
                    "printerId"     : options.printerId,
                    "printerAddress": options.printerAddress
                },
                "controller": "printer",
                "action"    : "setPrinterPrinterAddress"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 修改打印机状态查询地址
         */
        setPrinterPrinterInquire: function (options) {
            var out = {
                "params"    : {
                    "printerId"     : options.printerId,
                    "printerInquire": options.printerInquire
                },
                "controller": "printer",
                "action"    : "setPrinterPrinterInquire"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        setPrinterType: function (options) {
            var out = {
                "params"    : {
                    "printerId": options.printerId,
                    "type"     : options.type
                },
                "controller": "printer",
                "action"    : "setPrinterType"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 设置菜品分类的打印机
         */
        setCpGroupPrinter: function (options) {
            var out = {
                "params"    : {
                    "groupId"  : options.groupId,
                    "printerId": options.printerId
                },
                "controller": "printer",
                "action"    : "setCpGroupPrinter"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 设置一个菜品的打印机
         * @param options
         */
        setCpPrinter: function (options) {
            var out = {
                "params"    : options.cpToThePrinterList,//[{"cpId":"xxx","printerId":"yyy"},...]
                "controller": "printer",
                "action"    : "setCpPrinter"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 设置默认打印机
         */
        setDefaultPrinter: function (options) {
            var out = {
                "params"    : {
                    "printerId": options.printerId
                },
                "controller": "printer",
                "action"    : "setDefaultPrinter"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 获得打印记录
         * @param options
         */
        getPrintRecords: function (options) {
            var out = {
                "params"    : {},
                "controller": "printer",
                "action"    : "getPrintRecords"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 打印记录
         * @param options
         */
        printRecords: function (options) {
            var out = {
                "params"    : {
                    "id": options.id
                },
                "controller": "printer",
                "action"    : "printRecords"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 查询打印任务
         * @param options
         */
        queryPrintingTask: function (options) {
            var out = {
                "params"    : {
                    "type"  : options.type,
                    "taskId": options.taskId
                },
                "controller": "printer",
                "action"    : "queryPrintingTask"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getPrinterServerPrinterList: function (options) {
            var out = {
                "params"    : {},
                "controller": "printer",
                "action"    : "getPrinterServerPrinterList"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getAllPrinterList: function (options) {
            var out = {
                "params"    : {},
                "controller": "printer",
                "action"    : "getAllPrinterList"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        printerTest: function (options) {
            var out = {
                "params"    : {
                    "printerId": options.printerId
                },
                "controller": "printer",
                "action"    : "printerTest"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        printerTestAll: function (options) {
            var out = {
                "params"    : {},
                "controller": "printer",
                "action"    : "printerTestAll"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /***********************************
         * 统计的操作
         ***********************************/

        /**
         * 一段时间某一种支付方式（all 是全部的支付方式），每一天的收入金额
         * @param options
         */
        payTransToDailySalesByPayTypeAndDateRange: function (options) {
            var out = {
                "params"    : {
                    "start"  : options.start,
                    "end"    : options.end,
                    "payType": options.payType
                },
                "controller": "pay",
                "action"    : "payTransToDailySalesByPayTypeAndDateRange"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 一段时间某一种支付方式（all 是全部的支付方式），收入的合计金额
         * @param options
         */
        payTransSalesByPayTypeAndDateRange: function (options) {
            var out = {
                "params"    : {
                    "start"  : options.start,
                    "end"    : options.end,
                    "payType": options.payType
                },
                "controller": "pay",
                "action"    : "payTransSalesByPayTypeAndDateRange"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 一段时间某一种支付方式（all 是全部的支付方式），收入的合计金额
         * @param options
         */
        getUserIdPayAmountByDate: function (options) {
            var out = {
                "params"    : {
                    "start"  : options.start,
                    "end"    : options.end,
                    "payType": options.payType
                },
                "controller": "pay",
                "action"    : "getUserIdPayAmountByDate"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 一段时间某一种支付方式（all 是全部的支付方式），全部会员每天的充值金额
         * @param options
         */
        memberRechargeAmountToDailyByPayTypeAndDateRange: function (options) {
            var out = {
                "params"    : {
                    "start"  : options.start,
                    "end"    : options.end,
                    "payType": options.payType
                },
                "controller": "member",
                "action"    : "memberRechargeAmountToDailyByPayTypeAndDateRange"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 一段时间某一种支付方式（all 是全部的支付方式），全部会员的充值的合计金额
         * @param options
         */
        memberRechargeAmountByPayTypeAndDateRange: function (options) {
            var out = {
                "params"    : {
                    "start"  : options.start,
                    "end"    : options.end,
                    "payType": options.payType
                },
                "controller": "member",
                "action"    : "memberRechargeAmountByPayTypeAndDateRange"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 一段时间全部会员每天的消费金额
         * @param options
         */
        memberSpendAmountToDailyByPayTypeAndDateRange: function (options) {
            var out = {
                "params"    : {
                    "start": options.start,
                    "end"  : options.end
                },
                "controller": "member",
                "action"    : "memberSpendAmountToDailyByPayTypeAndDateRange"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 一段时间全部会员消费的合计金额
         * @param options
         */
        memberSpendAmountByPayTypeAndDateRange: function (options) {
            var out = {
                "params"    : {
                    "start": options.start,
                    "end"  : options.end
                },
                "controller": "member",
                "action"    : "memberSpendAmountByPayTypeAndDateRange"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 一道菜一天的销量
         */
        statLineItemCpOneDayCount: function (cId, day, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "CId": cId,
                    "Day": day
                },
                "controller": "cp",
                "action"    : "statLineItemCpOneDayCount"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /**
         * 一道菜一月的销量
         */
        statLineItemCpMonthCount: function (cId, day, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "CId": cId,
                    "Day": day
                },
                "controller": "cp",
                "action"    : "statLineItemCpMonthCount"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },


        getNEXByDateTime: function (options) {
            var out = {
                "params"    : {
                    "start": options.start,
                    "end"  : options.end
                },
                "controller": "pay",
                "action"    : "getNEXByDateTime"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },


        /**
         * 获得一段时间会员每天增加的数目
         */
        getMemberCountByDateRangeAccordingToTheDaily: function (start, end, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "start": start,
                    "end"  : end
                },
                "controller": "stat",
                "action"    : "getMemberCountByDateRangeAccordingToTheDaily"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        getImage: function (imageId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "imageId": imageId
                },
                "controller": "file",
                "action"    : "getImageBase64"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        getImageList: function (successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {},
                "controller": "file",
                "action"    : "getImageList"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /***********************************
         * 线上支付的操作
         ***********************************/

        initQrPay: function (type, orderId, amount, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "Type"   : type,
                    "OrderId": orderId,
                    "amount" : amount
                },
                "controller": "pay",
                "action"    : "initQrPay"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        checkQrPay: function (out_trade_no, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "out_trade_no": out_trade_no
                },
                "controller": "pay",
                "action"    : "checkQrPay"

            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /***********************************
         * 支付方式
         ***********************************/
        initPayType: function (options) {
            var out = {
                "params"    : {},
                "controller": "payType",
                "action"    : "initPayType"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        newPayType: function (newPayType, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : newPayType,
                "controller": "payType",
                "action"    : "newPayType"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        setPayTypeNameById: function (payTypeId, name, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "payTypeId": payTypeId,
                    "name"     : name
                },
                "controller": "payType",
                "action"    : "setPayTypeNameById"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        actionPayType: function (payTypeId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "payTypeId": payTypeId,
                    "status"   : "active"
                },
                "controller": "payType",
                "action"    : "setPayTypeStatusById"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        deactionPayType: function (payTypeId, successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "payTypeId": payTypeId,
                    "status"   : "inactive"
                },
                "controller": "payType",
                "action"    : "setPayTypeStatusById"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        getActivePayTypeList: function (successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "status": "active"
                },
                "controller": "payType",
                "action"    : "getPayTypeListByStatus"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        getInactivePayTypeList: function (successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {
                    "status": "inactive"
                },
                "controller": "payType",
                "action"    : "getPayTypeListByStatus"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        getPayTypeList: function (successFunction, errorFunction, completeFunction) {
            var out = {
                "params"    : {},
                "controller": "payType",
                "action"    : "getPayTypeList"
            };
            request(out, successFunction, errorFunction, completeFunction);
        },

        /***********************************
         * 聊天
         ***********************************/

        /**
         * 聊天，发言
         * @param options
         */
        newDialogue: function (options) {
            var out = {
                "params"    : {
                    "openId"  : options.openId,
                    "NickName": options.nickName,
                    "content" : options.content,
                    "tableId" : options.tableId
                },
                "controller": "chat",
                "action"    : "newDialogue"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 获得聊天消息
         * @param options
         */
        getDialogueByStartId: function (options) {
            var out = {
                "params"    : {
                    "id": options.id
                },
                "controller": "chat",
                "action"    : "getDialogueByStartId"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /***********************************
         * 口味
         ***********************************/

        newOrderRequest: function (options) {
            var out = {
                "params"    : {
                    "content": options.content
                },
                "controller": "orderRequest",
                "action"    : "newOrderRequest"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 删除口味
         * @param options
         */
        deleteOrderRequestByOrderRequestId: function (options) {
            var out = {
                "params"    : {
                    "orderRequestId": options.orderRequestId
                },
                "controller": "orderRequest",
                "action"    : "deleteOrderRequestByOrderRequestId"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        setOrderRequestContentById: function (options) {
            var out = {
                "params"    : {
                    "orderRequestId": options.orderRequestId,
                    "content"       : options.content
                },
                "controller": "orderRequest",
                "action"    : "setOrderRequestContentById"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 获得订单口味种类
         * @param options
         */
        getOrderRequestClassList: function (options) {
            var out = {
                "params"    : {},
                "controller": "orderRequest",
                "action"    : "getOrderRequestClassList"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /***********************************
         * 取 Cookie 值
         ***********************************/

        getCookie: function (c_name) {
            if (document.cookie.length > 0) {
                c_start = document.cookie.indexOf(c_name + "=");
                if (c_start != -1) {
                    c_start = c_start + c_name.length + 1;
                    c_end = document.cookie.indexOf(";", c_start);
                    if (c_end == -1) c_end = document.cookie.length;
                    return unescape(document.cookie.substring(c_start, c_end))
                }
            }
            //else {
            //    var str = localStorage.getItem(c_name);
            //    if (str) {
            //        var obj = JSON.parse(str);
            //        if (obj.expire < Date.parse(new Date()) / 1000) {
            //            localStorage.removeItem(c_name);
            //        } else {
            //            return obj.value;
            //        }
            //    }
            //}

            return ""
        },

        getCookieRId: function () {
            return this.getCookie("RId");
        },

        getCookieTId: function () {
            return this.getCookie("TId");
        },

        getCookieWeiXinOpenId: function () {
            return this.getCookie("openId");
        },

        getCookieWeiXinUnionid: function () {
            if (this.getCookie('userInfo') == "") {
                return "";
            }
            var userInfo = JSON.parse(this.getCookie('userInfo'));
            return userInfo.unionid;
        },

        getCookieWeiXinNickName: function () {
            if (this.getCookie('userInfo') == "") {
                return "";
            }
            var userInfo = JSON.parse(this.getCookie('userInfo'));
            return userInfo.nickname;
        },

        getCookieWeiXinSex: function () {
            if (this.getCookie('userInfo') == "") {
                return "";
            }
            var userInfo = JSON.parse(this.getCookie('userInfo'));
            return userInfo.sex;
        },

        getCookieWeiXinHeadimdurl: function () {
            if (this.getCookie('userInfo') == "") {
                return "";
            }
            var userInfo = JSON.parse(this.getCookie('userInfo'));
            return userInfo.headimgurl;
        },

        getCookieWeiXinSubscribe: function () {
            if (this.getCookie('userInfo') == "") {
                return "";
            }
            var userInfo = JSON.parse(this.getCookie('userInfo'));
            return userInfo.subscribe;
        },

        getCookieWeiXinUserInfo: function () {
            if (this.getCookie('userInfo') == "") {
                return "";
            }
            return JSON.parse(this.getCookie('userInfo'));
        },

        getCookieEzcMember: function () {
            if (this.getCookie('ezcMember') == "") {
                return "";
            }
            return JSON.parse(this.getCookie('ezcMember'));
        },

        getCookieMember: function () {
            if (this.getCookie('member') == "") {
                return "";
            }
            return JSON.parse(this.getCookie('member'));
        },

        /***********************************
         * 专用接口
         ***********************************/

        /**
         * 获得店内点餐流程首页新信息个数
         * @param options
         */
        getHomePageInfo: function (options) {
            var out = {
                "params"    : {
                    "tableId": options.tableId,
                    "openId" : options.openId

                },
                "controller": "pageInfo",
                "action"    : "getHomePageInfo"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getShareUrl: function (options) {
            var out = {
                "params"    : {
                    "orderId": options.orderId,
                    "openId" : options.openId
                },
                "controller": "order",
                "action"    : "getShareUrl"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getRestaurantHomeShareUrl: function (options) {
            var out = {
                "params"    : {
                    "orderId": options.orderId,
                    "openId" : options.openId
                },
                "controller": "order",
                "action"    : "getRestaurantHomeShareUrl"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * approx distance between two points on earth ellipsoid
         * @param {Object} lat1
         * @param {Object} lng1
         * @param {Object} lat2
         * @param {Object} lng2
         */
        getFlatternDistance: function (lat1, lng1, lat2, lng2) {
            var f = getRad((lat1 * 1 + lat2 * 1) / 2);
            var g = getRad((lat1 - lat2) / 2);
            var l = getRad((lng1 - lng2) / 2);
            //alert(JSON.stringify({lat1: lat1, lng1: lng1, lat2: lat2, lng2: lng2, f: f, g: g, l: l}));
            var sg = Math.sin(g);
            var sl = Math.sin(l);
            var sf = Math.sin(f);

            var s, c, w, r, d, h1, h2;
            var a = EARTH_RADIUS;
            var fl = 1 / 298.257;

            sg = sg * sg;
            sl = sl * sl;
            sf = sf * sf;

            s = sg * (1 - sl) + (1 - sf) * sl;
            c = (1 - sg) * (1 - sl) + sf * sl;

            w = Math.atan(Math.sqrt(s / c));
            r = Math.sqrt(s * c) / w;
            d = 2 * w * a;
            h1 = (3 * r - 1) / 2 / c;
            h2 = (3 * r + 1) / 2 / s;

            return d * (1 + fl * (h1 * sf * (1 - sg) - h2 * (1 - sf) * sg));
        },

        /***********************************
         * test
         ***********************************/
        getTest: function (options) {
            var out = {
                "params"    : {},
                "controller": "test",
                "action"    : "getTest"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        setTest: function (options) {
            var out = {
                "params"    : {},
                "controller": "test",
                "action"    : "setTest"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        removeTest: function (options) {
            var out = {
                "params"    : {},
                "controller": "test",
                "action"    : "removeTest"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getCapt_sendOpenTableInviteCaptSms: function (options) {
            var out = {
                "params"    : {},
                "controller": "test",
                "action"    : "getCapt_sendOpenTableInviteCaptSms"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        getCapt_verificationAddMemberAndOpenIdSMS: function (options) {
            var out = {
                "params"    : {},
                "controller": "test",
                "action"    : "getCapt_verificationAddMemberAndOpenIdSMS"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        test_orderSnapshot: function (options) {
            var out = {
                "params"    : {
                    "orderId": options.orderId
                },
                "controller": "order",
                "action"    : "test_orderSnapshot"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        text_sendTemplate_weiXinThePublic: function (options) {
            var out = {
                "params"    : {
                    "restaurantId": options.restaurantId
                },
                "controller": "test",
                "action"    : "sendTemplate_weiXinThePublic"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        //本地打印机接口
        localPrint: function (options) {
            var out = {
                "params"    : {
                    "orderId": options.orderId,
                    "logo"   : options.logo,
                    "header" : options.header,
                    "type"   : options.type,
                    "footer" : options.footer
                },
                "controller": "order",
                "action"    : "localPrint"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        //本地打印机接口
        localPrinter: function (options) {
            var out = {
                "params"    : {
                    "logo"   : options.logo,
                    "header" : options.header,
                    "title"  : options.title,
                    "content": options.content,
                    "footer" : options.footer,
                    //"qrCode": options.qrCode
                },
                "controller": "printer",
                "action"    : "localPrinter"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 修改桌台人数
         * @param options
         */
        changePersonCount: function (options) {
            var out = {
                "params"    : {
                    "orderId"    : options.orderId,
                    "personcount": options.personcount
                },
                "controller": "order",
                "action"    : "changePersonCount"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * LineItem加入服务员姓名
         * @param options
         */
        setWaiterName: function (options) {
            var out = {
                "params"    : {
                    "orderId"   : options.orderId,
                    "WaiterName": options.WaiterName
                },
                "controller": "order",
                "action"    : "setWaiterName"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 统计一段时间某一桌就餐人数
         * @param options
         */
        findPersonCountByDate: function (options) {
            var out = {
                "params"    : {
                    "start"  : options.start,
                    "end"    : options.end,
                    "tableId": options.tableId
                },
                "controller": "order",
                "action"    : "findPersonCountByDate"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 所有退菜数量统计
         * @param options
         */
        findStatusWrong: function (options) {
            var out = {
                "params"    : {
                    "start": options.start,
                    "end"  : options.end
                },
                "controller": "order",
                "action"    : "findStatusWrong"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 所有免单数量统计
         * @param options
         */
        findStatusFree: function (options) {
            var out = {
                "params"    : {
                    "start": options.start,
                    "end"  : options.end
                },
                "controller": "order",
                "action"    : "findStatusFree"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },

        /**
         * 当前订单金额
         * @param options
         */
        getLineItemPriceByOrderId: function (options) {
            var out = {
                "params"    : {
                    "orderId": options.orderId
                },
                "controller": "order",
                "action"    : "getLineItempriceByOrderId"
            };
            request(out, options.successFunction, options.errorFunction, options.completeFunction);
        },
    }
}();